chore: codebase optimization — reduce duplication, modernize Go, add linting and tests#30
Merged
qasim-nylas merged 9 commits intomainfrom Mar 10, 2026
Merged
Conversation
…linting and tests
- Add .golangci.yml (v2) with security, style, and bug linters
- Add gofmt check and govulncheck to CI pipeline
- Wire auto-format hook for Write tool in settings.json
- Replace interface{} with any across 31 test files
- Replace sort.Slice with slices.SortFunc (Go 1.21+)
- Split oversized test files (audit_hooks 839→4 files, format 659→3 files, gpg encrypt 681→3 files)
- Add new tests: audit commands (34 cases), audit helpers (52 cases), httputil (18 cases)
- Deduplicate .claude/ docs: consolidate credential storage, remove stale references
- Condense HOOKS-CONFIG.md (272→107 lines), README.md (174→133 lines), CLAUDE.md (254→231 lines)
- Remove deprecated generate-crud-command.md
659 insertions, 2982 deletions across 62 files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Pin golangci-lint-action to v2.11.1 (was resolving to v1 which rejects v2 config syntax) - Run gofmt on email_gpg_test.go and test.go (pre-existing formatting issues caught by new CI check) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Action v6 does not support golangci-lint v2. Upgrade to v7. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI was using Go 1.24 which has 5 known stdlib vulnerabilities (crypto/x509, html/template, net/url, os) that cause govulncheck to fail. Go 1.26 includes all fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace hardcoded ANSI color expectations with dynamic offset computation so TestGetTimezoneColor doesn't break during DST transitions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive codebase optimization across CI infrastructure, Go modernization, test coverage, and documentation deduplication.
.golangci.yml(v2) withdurationcheck,reassign,gofmt,goimportslintersgofmtcheck andgovulncheckvulnerability scanningsort.Slicewithslices.SortFunc,interface{}withany.claude/config — remove ~450 lines of duplicated contentNet: +3,342 / −2,646 across 63 files. All CI checks pass (
make ci-full).Changes by Category
1. CI & Linting Infrastructure
.golangci.yml.github/workflows/ci.ymlgofmtformatting check +govulncheckvulnerability scan.claude/settings.jsonauto-format.shhook forWritetool (was only onEdit)2. Go Modernization (34 files)
interface{}→anysort.Slice→slices.SortFuncstore.go,memory.go,logs_summary.go— uses Go 1.21+ stdlibv := x.(T)→v, _ := x.(T)to satisfy errcheckbehaviour→behavior(US English)3. Oversized Test File Splits (3 → 10 files)
cli/audit_hooks_test.goaudit_hooks_context_test.go(125),audit_hooks_sanitize_test.go(230),audit_hooks_identity_test.go(284),audit_hooks_lifecycle_test.go(218)cli/common/format_test.goformat_parse_test.go(60),format_output_test.go(271),format_table_test.go(347)adapters/gpg/encrypt_test.godecrypt_test.go(216),keys_test.go(186)All tests preserved — no logic changes, just file reorganization by responsibility.
4. New Tests (+1,053 lines, 104 cases)
internal/cli/audit/commands_test.gointernal/cli/audit/helpers_test.gointernal/httputil/httputil_test.go5.
.claude/Config Deduplication (~450 lines removed)CLAUDE.md.claude/HOOKS-CONFIG.md.claude/README.md.claude/commands/add-api-method.mdadapter-patterns.md.claude/commands/add-domain-type.mddomain-patterns.md.claude/commands/generate-crud-command.md/add-command.claude/commands/generate-tests.md/run-tests.claude/commands/update-docs.mddocumentation-maintenance.md.claude/agents/references/security-checklist.md6. Pre-existing Lint Fixes
mcp/proxy_forward_test.go_, _patternmcp/proxy_response_extra_test.go_, _patternTest plan
make cipasses (fmt, vet, lint, unit tests, race detector, security, vuln, build)make ci-fullpasses (above + integration tests + cleanup)golangci-lint run --new-from-rev=mainreports 0 issues